<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css"/>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
		<style type="text/css">
			
			.pherder{
				width: 100%;
				display: flex;
				justify-content: center;
				align-content: center;
				background-color: white;
				padding: 0.8em;
				margin-bottom: 0.4em;
			}
			.pimg{
				width: 20%;
				padding: 0.6em;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.pimg>img{
				width: 100%;
				border-radius:50%;
			}
			.pcontent{
				width: 60%;
				display: flex;
				justify-content: center;
				align-items: flex-start;
				flex-direction: column;
			}
			.pright{
				width: 20%;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.rimg{
				width: 40px;
				height: 40px;
			}
			.rimg>img{
				width: 100%;
				height: 100%;
			}
			.pname{
				padding: 0.5em;
			}
			.ptime,.pmess{
				padding: 0.2em 0.5em;
			}
			.mbe4{
				margin-bottom: 0.4em;
			}
			
			*{
				font-size: 0.95em;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <!--
            	作者：592176224@qq.com
            	时间：2019-01-03
            	描述：
            	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
            -->
		    <h1 class="mui-title">我的</h1>
		</header>
		<div id="refreshContainer" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
		    <div class="pherder" id="pherderid">
		    	<div class="pimg">
		    		<img id="storeimg" src="../images/user-photo.png"/>
		    	</div>
		    	<div class="pcontent">
		    		<div class="pname">
		    			<span id="storename"></span>
		    		</div>
		    		<div class="pmess fe09" >
		    			联系方式： <span id="storephone"></span> 
		    		</div>
		    		<div class="ptime fe09" >
		    			有效日期： <span id="storetime"></span> 
		    		</div>
		    		<div class="ptime fe09" >
		    			可用短信： <span id="viable_message_count"></span> 
		    		</div>
		    	</div>
		    	<div class="pright">
		    		<div class="rimg" id="setpersonal">
		    			<img src="img/bj.png"/>
		    		</div>
		    	</div>
		    </div>
		    
		    <div class="mbe4">
		    	<ul class="mui-table-view">
		    	        <li class="mui-table-view-cell" id="systemsetting" >
		    	            <a class="mui-navigate-right">
		    	                系统设置
		    	            </a>
		    	        </li>
		    	        <li class="mui-table-view-cell" id="setpassword">
		    	            <a class="mui-navigate-right">
		    	                 修改密码
		    	            </a>
		    	        </li>
		    	    </ul>
		    </div>
		    
		    <div class="mbe4">
		    	<ul class="mui-table-view">
		    	        <li class="mui-table-view-cell" id="aboutUs" >
		    	            <a class="mui-navigate-right">
		    	                关于我们
		    	            </a>
		    	        </li>
		    	        <!--
                        	作者：592176224@qq.com
                        	时间：2019-04-01
                        	描述：
                        
		    	        <li class="mui-table-view-cell" onclick="gopage4('share')">
		    	            <a class="mui-navigate-right">
		    	                 分享软件
		    	            </a>
		    	        </li>
		    	        -->
		    	        <li class="mui-table-view-cell" id="reception" >
		    	            <a class="mui-navigate-right">
		    	                 您的客服
		    	            </a>
		    	        </li>
		    	       
                        
		    	        <li class="mui-table-view-cell" id="gohelp" >
		    	            <a class="mui-navigate-right">
		    	                 帮助中心
		    	            </a>
		    	        </li>
		    	       
		    	        <li class="mui-table-view-cell" id="checkVersion" >
		    	            <a class="mui-navigate-right">
		    	                 版本管理
		    	            </a>
		    	            <span class="mui-badge mui-badge-primary" id="vspan">
		    		    	
		    		   		</span>
		    	        </li>
		    	        <li class="mui-table-view-cell" id="gologing">
		    	            <a class="mui-navigate-right">
		    	                 退出登录
		    	            </a>
		    	        </li>
		    	    </ul>
		    		</div>
		    	</div>	
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			window.onload = function(){
				mui.init({
                        	pullRefresh : {
						    container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
						    down : {
						      height:50,//可选,默认50.触发下拉刷新拖动距离,
						      auto: false,//可选,默认false.首次加载自动下拉刷新一次
						      contentdown : "下拉可以刷新",//可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
						      contentover : "释放立即刷新",//可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
						      contentrefresh : "正在刷新...",//可选，正在刷新状态时，下拉刷新控件上显示的标题内容
						      callback :function (){
						      		console.log("下拉");
						      		getstore();
						      		getviable_message_count();
						      		mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
						      }
						    },
						  }
                });
                
                
                g("setpersonal").addEventListener("tap",function(){
                	gopage4('setpersonal');
                })
                g("systemsetting").addEventListener("tap",function(){
                	gopage4('systemsetting');
                })
                g("setpassword").addEventListener("tap",function(){
                	 gopage4('setpassword');
                })
                g("aboutUs").addEventListener("tap",function(){
                	gopage4('aboutUs');
                })
                g("reception").addEventListener("tap",function(){
                	 gopage4('reception');
                })
                g("gohelp").addEventListener("tap",function(){
                	gohelp();
                })
                g("checkVersion").addEventListener("tap",function(){
                	 checkVersion();
                })
                g("gologing").addEventListener("tap",function(){
                	  gologing();
                })
                
                
				//设置版本
				g("vspan").innerHTML = "V"+version;
				//获取门店信息
				getstore();
				//获取剩余短信
				getviable_message_count();
			}
			
			
			//注销或 关闭
			function gologing(){
            plus.nativeUI.actionSheet({
                cancel: "取消",
                buttons: [{
                    title: "注销当前账号"
                }, {
                    title: "直接关闭应用"
                }]
            }, function(e) {
                var index = e.index;
                switch (index) { //case 0: 取消
                    case 1: //
                        localStorage.clear();
                        localStorage.removeItem("accesstoken");
                        localStorage.removeItem("phone");
						localStorage.removeItem("psword");
                        plus.runtime.restart();
                        mui.currentWebview.close();
                        break;
                    case 2: //
                        plus.runtime.quit();
                        break;
                }
            });
				
			}
			//刷新函数，子页面调用
			function onshow(){
				getstore();
			}
			//页面跳转
			function gopage(url){
				mui.openWindow({
				    url: url +'.html', 
				    id: url
				 });
			}
			function gopage4(url){
				mui.openWindow({
                        url: url+".html",
                        id: url
                });
			}
			//获取短信数
			function getviable_message_count(){
				var data = {
					url:"/api/company/detail",
					data:{access_token:acctoken()}
				}
				ajax(data,function(res){
					console.log(res);
					g("viable_message_count").innerHTML = res.data.viable_message_count||0;
				})
				
				
			}
			
			function getstore(){
				var data = {
					url:"/api/store/detail",
					data:{
						access_token:acctoken(),
					}
				}
				ajax(data,function(res){
					console.log("门店信息",res);
					
					g("storename").innerHTML = res.data.store_name;
					g("storephone").innerHTML = res.data.phone;
					g("storetime").innerHTML = res.data.expire_time;
					if(res.data.images&&res.data.images.path_name){
						g("storeimg").src = res.data.images.path_name;
					}
				})
				
			}
			//帮助中心
			function gohelp(){
				console.log("帮助中心")
				plus.runtime.openURL("http://www.soft101.com/help/help.htm");//调用浏览器打开网址  
			}
			
			function checkVersion(){
				var data = {
					url:"/api/version/check",
					data:{
						access_token:acctoken(),
					}
				}
				ajax(data,function(res){
					console.log("版本",res);
					if(res.data.serial_number > parseFloat(version)){
						if(!is_ios()){
							var list = {vurl: res.data.path_url||"",content:res.data.content,serial_number:res.data.serial_number};
							mui.openWindow({
							    url: '../version-page.html?list='+JSON.stringify(list), 
							    id: 'version-page',
							    extras: list,
							 });
						}else{
							mui.toast("请到苹果商城更新版本")
						}
					 
					}else{
						console.log("最新版");
						mui.toast("当前版本是最新版");
					}
				})
			}
		</script>
	</body>

</html>